<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%
        String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>List</title>
        <script type="text/javascript" src="<%=path%>/js/jquery.js"></script>
        <script  type="text/javascript">
            $(document).ready(function(){
                $(':button[name="create"]').bind("click", function(){
                    window.location.href = "<%=path%>/person.htm?method=create";
                });
                $(':button[name="update"]').bind("click", function(){
                    window.location.href = "<%=path%>/person.htm?method=update&id=" + $(':radio[checked="true"]').val();
                });
                $(':button[name="delete"]').bind("click", function(){
                    $(':hidden').val("delete");
                    document.forms[0].submit();
                });
            });
        </script>
    </head>
    <body>
        <form action="<%=path%>/person.htm" method="get">
            <h1>用户列表</h1>
            <hr />
            <table>
                <tr>
                    <td>
                        姓名：<input type="text" name="name"  value="${param.name}" />
                        年龄：<input type="text" name="age" value="${param.age}" />
                        排序
                        <select name="order">
                            <option value="name">姓名 升序</option>
                            <option value="name desc">姓名 降序</option>
                            <option value="age">年龄 升序</option>
                            <option value="age desc">年龄 降序</option>
                        </select>
                        <input type="submit" value="查询" />
                        <input type="reset" value="重置" />
                        <input type="hidden" name="method" value="list" />
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>选择</td>
                    <td>序号</td>
                    <td>姓名</td>
                    <td>年龄</td>
                    <td>描述</td>
                </tr>
                <c:forEach varStatus="state" var="person" items="${list}">
                    <tr>
                        <td><input type="radio" name="id" value="${person.id}" /></td>
                        <td>${state.count}</td>
                        <td>${person.name}</td>
                        <td>${person.age}</td>
                        <td>${person.description}</td>
                    </tr>
                </c:forEach>
                <tr>
                    <td colspan="5">
                        <input type="button" name="create" value="新建" />
                        <input type="button" name="update" value="修改" />
                        <input type="button" name="delete" value="删除" />
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>
